package com.jic.market.common.exception.handler;

import com.alibaba.fastjson.JSONObject;
import com.jic.common.base.vo.RestResult;
import com.jic.market.common.exception.MarketException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.List;


/**
 * 自定义异常处理
 *
 * @author guohuayong
 * @date 2020/2/24 13:36
 **/
@RestControllerAdvice
@Slf4j(topic = "error")
public class CustomerExceptionHandler {

	@ExceptionHandler(value = MarketException.class)
	public RestResult processContractMisException(MarketException ex) {
		log.warn("MarketException {}", ex);

		return RestResult.error(ex.getCode(), ex.getMessage());
	}
}
